package mygang.dao;

import java.util.Properties;
import mygang.helper.Utils;
import org.apache.log4j.Logger;

/**
 *
 * @author Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
 * date: 24/02/2013
 */
public abstract class DAO {
    
    public static final String SERVER = "db.server";
    public static final String LOGIN = "db.username";
    public static final String PASSWORD = "db.password";
    public static final String DRIVER = "db.driver";
    public static final String NAME = "db.name";

    private static final Logger log = Logger.getLogger(DAO.class.toString());
    private static final String PROPERTY_FILE = "/db.properties";
    private static Properties settings;

    /**
     * Returns property value by name
     * @param propertyName defines property name
     * @return property value
     */
    public static String getProperty(String propertyName){
        return getSettings().getProperty(propertyName);
    }
    
    private static Properties getSettings(){
        return settings==null ? settings = Utils.readProps(PROPERTY_FILE) : settings;
    }

}